package com.weiz.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    final static String message = "order.queue";
    //定义队列
    @Bean
    public Queue queueMessage() {
        return new Queue(message);
    }
    //交换机
    @Bean
    TopicExchange exchange() {
        return new TopicExchange("order.exchange");
    }
    //将队列和交换机绑定
    @Bean
    Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) {
        return BindingBuilder.bind(queueMessage).to(exchange).with("order.message"
        );
    }
}